<template>
	<view>
		<template v-if="url">
			<web-view :src="url" @message="postMessage"></web-view>
		</template>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				url:""
			}
		},
		onLoad(e) {
			let decodedString = decodeURIComponent(e.url);
			this.url = decodedString;
		},
		methods: {
			postMessage(e){
				if(JSON.parse(e.detail.data).code === 0){
					// 这里的同步储存用于通知上一页的重新加载
					uni.setStorageSync('extendWebView', 'update');
					uni.navigateBack()
				}else{
					uni.showToast({
						title: e,
						duration: 1500
					});
				}
			}
		}
	}
</script>

<style>

</style>
